Is `eval`ing in a CPAN module without localizing $@ a bug?

Posted by rassie on Stack Overflow See other posts from Stack Overflow or by rassie
Published on 2010-06-01T12:13:33Z Indexed on 2010/06/01 15:43 UTC
Read the original article Hit count: 189

Filed under:
|
|
|

I think I've encountered a bug in Params::Validate, but I'm not sure whether I identified the problematic code piece correctly. The code in question failed to pass exceptions up the chain (using Try::Tiny), so I started debugging and found out that a class used inside the try block has a destructor. This destructor calls object methods which use Params::Validate and looking into Validate.pm source I see an eval without $@ localization, i.e. the global $@ gets overwritten.

Now I see two options:

  1. Params::Validate should always localize $@ and thus it's a bug that should be reported.
  2. The bug is in the class in question, because it shouldn't use Params::Validate in a destructor. Params::Validate can stay as it is now.

Which one is it? How I should I handle this situation?

PS: I think that CPAN modules should be rock-solid and neither break themselves nor their environment, hence the question title.

© Stack Overflow or respective owner

Related posts about perl

Related posts about bugs